// src/router/index.tsx
import { createBrowserRouter } from "react-router";
import AppLayout from "../layouts/AppLayout";
import Dashboard from "../pages/Dashboard";
import Chat from "../pages/Chat";
import Role from "../pages/Role";
import Login from "../pages/Login";
import Register from "../pages/Register";
import { requireAuth } from "./RequireAuth";

const router = createBrowserRouter([
  {
    path: "/login",
    //loader: requireGuest,  已登录时重定向到 dashboard
    Component: Login,
  },
  {
    path: "/register",
    Component: Register,
  },
  {
    path: "/",
    Component: AppLayout,
    loader: requireAuth,
    children: [
      {
        index: true,
        Component: Dashboard,
      },
      {
        path: "role",
        Component: Role,
      },
      {
        path: "conversation/:sessionId",
        Component: Chat,
      },
    ],
  },
]);

export default router;
